﻿using System;

namespace LayeredArchitectureSample.DomainModel
{
    [GenerateDefaultViewModel]
    public abstract class DomainObject
    {
        protected DomainObject(long id)
        {
            if (id < 0)
            {
                throw new ArgumentOutOfRangeException("id");
            }

            Id = id;
        }

        public long Id { get; private set; }

        public override bool Equals(object obj)
        {
            DomainObject otherObjectAsDomainObject = obj as DomainObject;

            if (otherObjectAsDomainObject == null)
            {
                return false;
            }

            return otherObjectAsDomainObject.Id.Equals(this.Id);
        }

        public override int GetHashCode()
        {
            return Id.GetHashCode();
        }
    }

    // TODO
    public class GenerateDefaultViewModelAttribute : Attribute
    {
    }
}